// 改变this指向，并返回
var a = {
  name: '诩神'
}
var b = {
  name: '阿伟'
  // fn: function() {
  //   console.log(this.name);
  // }
}
// b.fn()

// 手写部分
Function.prototype.myapply = function(context, arguments) {
  context = context || window;
  context.fn = this;
  let args = [...arguments].slice(1);
  let result = context.fn(...args);
  delete context.fn;
  return result
}
function test(x, y, z) {
  console.log(this.name);
  console.log(x, y, z);
}
test.mycall(a, 1, 2, 3)
// 手写apply和bind